Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it now
Intall Later
Run
HTML
CSS
Javascript
Output
Document
40
weeks
36
weeks
32
weeks
28
weeks
24
weeks
20
weeks
16
weeks
12
weeks
8
weeks
4
weeks
Day:
Due date:
@charset "UTF-8"; @import url(https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800); *, :after, :before { box-sizing: border-box; padding: 0; margin: 0; } body { background: rgb(50, 0, 108); font-family: "Roboto", sans-serif; margin: 0, auto; } #babyProgression { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 100%; width: 100%; max-width: 100%; max-height: calc(100% - 250px); min-height: 100px; } .maskLine { transition: d 310ms; } .maskLine:nth-of-type(2) { transition: d 300ms; } .controls { position: absolute; top: 50%; left: 15px; transform: translate(0%, -50%); height: calc(100vh - 6em); max-height: 600px; } .slider { position: absolute; display: block; top: 50%; right: 15px; transform: translate(0%, -50%); width: 50px; height: calc(100vh - 6em); max-height: 600px; } #scaleSlider { position: absolute; width: calc(100vh - 6em); max-width: 600px; cursor: pointer; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-90deg); } .container { display: flex; flex-direction: column; width: 45px; justify-content: space-between; height: 100%; } .container > button { cursor: pointer; color: rgba(255, 255, 255, 0.5); background: none; border: 1px solid rgba(255, 255, 255, 0.5); flex: 1; margin: 0px; padding-top: 4px; padding-bottom: 4px; padding-left: 0px; padding-right: 0px; font-family: "Roboto", sans-serif; font-weight: bold; } .container > button:hover, .container > button:focus, .container > button:active { border: 1px solid #fff; color: #fff; } .container > button > span { font-weight: 100; font-size: 0.8em; } .daysSection { text-align: center; font-family: "Roboto", sans-serif; position: absolute; bottom: 10px; left: 50%; transform: translate(-50%); color: rgba(255, 255, 255, 0.8); } .days { font-size: 1.5em; font-weight: 600; } .dateSection { text-align: center; font-family: "Roboto", sans-serif; position: absolute; top: 10px; left: 50%; transform: translate(-50%); color: rgba(255, 255, 255, 0.8); } input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; cursor: pointer; outline: none; overflow: hidden; border-radius: 25px; } /* Track: webkit browsers */ input[type="range"]::-webkit-slider-runnable-track { height: 25px; background: rgb(50, 0, 108); border-radius: 25px; } /* Track: Mozilla Firefox */ input[type="range"]::-moz-range-track { height: 25px; background: rgb(50, 0, 108); border-radius: 25px; } /* Thumb: webkit */ input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; height: 25px; width: 25px; background-color: #a020f0; border-radius: 50%; border: 1px solid #a020f0; box-shadow: -407px 0 0 400px rgb(100, 0, 180); } /* Thumb: Firefox */ input[type="range"]::-moz-range-thumb { height: 25px; width: 25px; background-color: #a020f0; border-radius: 50%; border: 1px solid #a020f0; box-shadow: -407px 0 0 400px rgb(100, 0, 180); }
console.log("Event Fired") const slider = document.getElementById("animationSlider"); const scaleSlider = document.getElementById('scaleSlider'); const dateInput = document.getElementById("dueDate"); // Function to handle slider change function handleScaleChangeScale(val) { const percentage = (val / 252); const animations = document.querySelectorAll("#babyProgression animate"); document.querySelector('.days').textContent = parseInt(parseInt(val) + 28); // Change baby animations animations.forEach((animation) => { const duration = parseFloat(animation.getAttribute("dur")) || 50; // Calculate the target time let targetTime = duration * percentage; if (targetTime == 0){targetTime = 0.01}; if (targetTime == 100){targetTime = 99.9}; // Set the current time of the animation animation.ownerSVGElement.setCurrentTime(targetTime); // Freeze the animation animation.beginElementAt(-targetTime); animation.ownerSVGElement.pauseAnimations(); }); } function setProgress(num) { scaleSlider.value = num; handleScaleChangeScale(num); } // Attach event listener to the slider scaleSlider.addEventListener('input', (event) => { handleScaleChangeScale(event.target.value); }); function daysUntil(date) { let targetDate; if (typeof date === "string") { const [year, month, day] = date.split("-").map(Number); targetDate = new Date(year, month - 1, day); } else if (date instanceof Date) { targetDate = date; } else { throw new Error("Invalid date format. Please provide a Date object or a string in YYYY-MM-DD format."); } const today = new Date(); today.setHours(0, 0, 0, 0); const timeDiff = targetDate - today; const daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); return daysDiff; } function calculateDays() { const dateInputValue = dateInput.value; // Store the date in local storage localStorage.setItem("savedDueDate", dateInputValue); const days = daysUntil(dateInputValue); if ((252 - days) >= 0) { setProgress(252 - days); } } // Load the saved date from local storage if it exists function loadSavedDate() { const savedDate = localStorage.getItem("savedDueDate"); if (savedDate) { dateInput.value = savedDate; } } dateInput.addEventListener("input", calculateDays); // Load the saved date when the page loads loadSavedDate(); calculateDays();